package zhexian.app.smartcall.ui;

import android.app.Dialog;
import android.app.DialogFragment;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.util.Log;

import java.text.NumberFormat;

import zhexian.app.smartcall.MainActivity;

/**
 * Created by hling on 2016/1/6.
 */
public class ProgressFragement extends DialogFragment {
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        Log.i(MainActivity.TAG, "new Dialog");
        ProgressDialog dialog = new ProgressDialog(this.getActivity());
        dialog.setMessage("正在上传头像，请稍候...");
        dialog.setIndeterminate(false);
        dialog.setCancelable(false);
        dialog.setProgressPercentFormat(NumberFormat.getPercentInstance());
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);

        int max = getArguments().getInt("Max");
        if (max != 0) {
            dialog.setMax(max);
        }
        return dialog;
    }

    public void setMax(int max) {
        getArguments().putInt("Max", max);
    }
}
